浏览量 2443
2021/06/02 14:20
一次关于误操作dhclient-script故障记录
A dhclient-script failure record for an incorrect operation
起因
Causes
因有一个服务于aws的域名解析失败,导致业务无法正常发布.
国内解析aws的域名失败,国外正常.
此时有两个解决方法:
- 配置hosts
- 修改/etc/resolv.conf
修改hosts可临时解决问题,但如果aws换了指向,还需要再做修改。
所以使用第二种方法。
但当修改完 /etc/resolv.conf后,执行命令service network restart,会发现/etc/resolv.conf被重置,使修改失效。
经查是因为/usr/sbin/dhclient-script所致。
因一时疏忽直接执行了:
mv /usr/sbin/dhclient-script /usr/sbin/dhclient-scriptbak
service network restart
执行完后一脸懵逼,ec2成砖头了,链接断开,再也无法链接.
Due to a domain name resolution failure for AWS, the business cannot be published normally.
Domestic resolution of AWS domain failed, foreign normal.
There are two solutions:
-
The configuration of hosts
-
Modify the/etc/resolv. Conf
Modifying Hosts can solve the problem temporarily, but you will need to make further changes if AWS is directed elsewhere.
So use the second method.
But when modifying the/etc/resolv. Conf, execute the command service network restart, will find that the/etc/resolv. Conf reset, disable modification.
/usr/sbin/dhclient-script = /usr/sbin/dhclient-script = /usr/sbin/dhclient-script
To execute directly out of an oversight:
mv /usr/sbin/dhclient-script /usr/sbin/dhclient-scriptbak
service network restart
After the implementation of a face of muddled, EC2 into a brick, the link is broken, can not be linked.
开始修复
Begin to repair
修复思路:
将有问题磁盘挂载到一台正常能连接的ec2上,修复好后,再挂回来。
因这台ec2机器,上挂了两个磁盘,分别是 /dev/xvda(root device)和 /dev/sdb.
- 制作 /dev/xvda snapshot.
- 从snapshot创建volume.
- 将 volume 挂载到正常的 ec2 机器上 /dev/sdf1.
- 执行命令
mkdir /fix
mount /dev/sdf1 /fix
mv /fix/usr/sbin/dhclient-scriptbak /usr/sbin/dhclient-script
umount /dev/sdf1
- 在aws上将volume从正常的ec2 detach.
- 关机故障机器,卸载/dev/xvda.
- 将修复的volume重新挂载回故障ec2的root分区.分区路径 /dev/xvda
- 启动故障机器,完成修复.
repair idea:
mounts the defective disk to a normally connected EC2, fixes it, and then mounts it back.
has two disks mounted on this EC2 machine, /dev/xvda(root device) and /dev/sdb.
- Make /dev/xvda snapshot.
- Create volume from snapshot
- Mount the volume on /dev/sdf1 on a normal EC2 machine.
- Follow orders
mkdir /fix
mount /dev/sdf1 /fix
mv /fix/usr/sbin/dhclient-scriptbak /usr/sbin/dhclient-script
umount /dev/sdf1
- Remove the volume from normal EC2 detach on AWS.
- Shutdown the failed machine and uninstall /dev/xvda.
- Re-mount the repaired volume back into the root partition of the failed EC2. Partition path /dev/xvda
- Start the faulty machine and complete the repair.
dhclient-script 介绍
DHCP客户端的网络配置脚本不时地被dhclient调用。这个脚本被dhcp客户端用来在请求地址前设置每个接口的初始配置,在地址被提供后进行测试,并在获得租约后设置接口的最终配置。这个脚本并不意味着可以由终端用户进行定制。如果需要进行本地定制,应该可以使用所提供的输入和输出钩子。这些钩子将允许用户在创建/etc/resolv.conf文件时覆盖客户端的默认行为。当它启动时,客户端脚本首先定义了一个shell函数,make_resolv_conf,它随后被用来创建/etc/resolv.conf文件。要推翻默认行为,请在进入钩子脚本中重新定义这个函数。
dhclient-script Introduction
The DHCP client network configuration script is invoked from time to time by dhclient. This script is used by the dhcp client to set each interface’s initial configuration prior to requesting an address, to test the address once it has been offered, and to set the interface’s final configuration once a lease has been acquired. This script is not meant to be customized by the end user. If local customizations are needed, they should be possible using the enter and exit hooks provided. These hooks will allow the user to override the default behavior of the client in creating a /etc/resolv.conf file. When it starts, the client script first defines a shell function, make_resolv_conf, which is later used to create the /etc/resolv.conf file. To override the default behavior, redefine this function in the enter hook script.
上一篇 搜索 下一篇